//
//  UUDriverPicker.m
//  UUCharterSupplier
//
//  Created by ZhangAo on 23/02/2018.
//  Copyright © 2018 UUCharter. All rights reserved.
//

#import "UUDriverPicker.h"

@interface UUDriverPicker ()

@end

@implementation UUDriverPicker

static UIViewController *_picker;
+ (UIViewController *)pickerWithFleetId:(NSNumber *)fleetId completeBlock:(void (^)(id))completeBlock {
    UUDriverPicker *picker = [self instanceOfAppropriate];
    picker.title = @"请选择司机";
    picker.fleetId = fleetId;
    WEAK_SELF();
    picker.didSelectDriverBlock = ^(id driverId) {
        completeBlock(driverId);
        [weakSelf dismiss];
    };
    picker.navigationItem.leftBarButtonItem = [UIBarButtonItem barButtonItemWithTitle:@"取消"
                                                                               target:self
                                                                             selector:@selector(dismiss)];
    _picker = picker;
    return [[UINavigationController alloc] initWithRootViewController:picker];
}

+ (void)dismiss {
    [_picker dismissViewControllerAnimated:YES completion:nil];
    _picker = nil;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
